package com.crape.account.dao.impl;

import java.util.HashMap;
import java.util.Map;

import com.crape.account.dao.IAccountRefDAO;
import com.crape.common.exceptions.DAOException;
import com.crape.common.ibatis.SqlMapClientDaoSupportEx;

public class AccountRefDAOImpl extends SqlMapClientDaoSupportEx implements IAccountRefDAO {

    @Override
    public Long countAcctRefs(Long fansid, Long accountid) throws DAOException {
        if (fansid == null && accountid == null) {
            return 0L;
        }
        Map<String, Long> params = new HashMap<String, Long>();
        params.put("fansid", fansid);
        params.put("accountid", accountid);
        return (Long) this.queryObject("countAcctRefs", params);
    }

    @Override
    public void insertAcctRef(Long fansid, Long accountid) throws DAOException {
        if (fansid == null || accountid == null) {
            return;
        }
        Map<String, Long> params = new HashMap<String, Long>();
        params.put("fansid", fansid);
        params.put("accountid", accountid);
        this.insert("insertAcctRef", params);
    }

    @Override
    public void deleteAcctRef(Long fansid, Long accountid) throws DAOException {
        if (fansid == null || accountid == null) {
            return;
        }
        Map<String, Long> params = new HashMap<String, Long>();
        params.put("fansid", fansid);
        params.put("accountid", accountid);
        this.delete("deleteAcctRef", params);
    }

    @Override
    public void backupAcctRef(Long fansid, Long accountid) throws DAOException {
        if (fansid == null || accountid == null) {
            return;
        }
        Map<String, Long> params = new HashMap<String, Long>();
        params.put("fansid", fansid);
        params.put("accountid", accountid);
        this.insert("backupAcctRef", params);
    }

}
